package com.wealth.system.service;

import java.io.Serializable;

import org.apache.shiro.SecurityUtils;

import com.wealth.member.entity.Member;
import com.wealth.system.entity.User;
/**
 * 登录用户
 * @author chan
 *
 */
public class ShiroMember implements Serializable{

	/**
	 * 
	 */
	private static final long serialVersionUID = 4493044635335604264L;
	
	
	private Member member;
	
	/**
	 * 取出Shiro中的当前用户
	 */
	public static ShiroMember getInstance() {
		Member member =(Member)SecurityUtils.getSubject().getPrincipal();
 		if(member==null){
 			return null;
 		}
 		return new ShiroMember(member);
	}
	
	private ShiroMember(){};
	private ShiroMember(Member member) {
		this.member = member;
	}
 
	 
	public Member getMember() {
		return member;
	}

	public void setMember(Member member) {
		this.member = member;
	}

	/**
	 * 本函数输出将作为默认的<shiro:principal/>输出.
	 */
	@Override
	public String toString() {
		return member.getUsername();
	}
	
}
